﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

using ClassDll;
using Company;
using Logger;

namespace ProgramGUI
{
    public partial class Form1 : Form
    {
        
        public Form1()
        {
            CenterToScreen();
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            company = Factory.CreateCompany();
            logger = LoggerFactory.CreateLogger();

            logger.Log("Начало работы с программой.");

            listOfPlanes.Items.Add(Factory.CreatePlane(0));
            listOfPlanes.Items.Add(Factory.CreatePlane(1));
            listOfPlanes.Items.Add(Factory.CreatePlane(2));

            logger.Log("Добавлены самолеты.");
        }

        private void buttonAdd_Click(object sender, EventArgs e)
        {
            if (listOfPlanes.SelectedItem is Object)
            {
                company.addPlane(listOfPlanes.SelectedItem);
                logger.Log("Самолет '" + listOfPlanesCompany.GetItemText(listOfPlanes.SelectedItem) + "' добавлен в ангар.");

                listOfPlanesCompany.Items.Add(listOfPlanes.SelectedItem);

                valueCost.Text = company.calculateTotalPassangers().ToString() + " человек.";
            }
        }

        private void buttonDelete_Click(object sender, EventArgs e)
        {
            if (listOfPlanesCompany.SelectedItem is Object)
            {
                company.removePlane(listOfPlanesCompany.SelectedIndex);
                logger.Log("Самолет '" + listOfPlanesCompany.GetItemText(listOfPlanesCompany.SelectedItem) + "' удален из ангара.");

                listOfPlanesCompany.Items.Remove(listOfPlanesCompany.SelectedItem);

                valueCost.Text = company.calculateTotalPassangers().ToString() + " человек.";
            }
        }

        private void Form1_FormClosing(object sender, FormClosingEventArgs e)
        {
            logger.Log("Конец работы с программой.");
        }

        private void labelFlowers_Click(object sender, EventArgs e)
        {

        }

        private void valueCost_Click(object sender, EventArgs e)
        {

        }
    }
}
